package com.example.demo.streamstudy;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description StreamTest1
 * @Author songchuanlong
 * @Date 2025-05-21
 */
public class StreamTest1 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        List<String> newList = new ArrayList<>();
        Collections.addAll(list,"张无忌","周芷若","赵敏","张强","张三丰");
        //找出姓张，且是3个字的名字，存入到一个新集合中去。
        List<String> collectZhang = list.stream().filter(k -> k.startsWith("张") && k.length() == 3).collect(Collectors.toList());
        System.out.println(collectZhang);
    }
}
